<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<title>FCKeditor - Sample</title>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<meta name="robots" content="noindex, nofollow" />
	<link href="../sample.css" rel="stylesheet" type="text/css" />
	<script type="text/javascript" src="fckeditor.js"></script>
	<script type="text/javascript">

window.onload = function()
{
	// Automatically calculates the editor base path based on the _samples directory.
	// This is usefull only for these samples. A real application should use something like this:
	// oFCKeditor.BasePath = '/fckeditor/' ;	// '/fckeditor/' is the default value.
	var sBasePath = document.location.pathname.substring(0,document.location.pathname.lastIndexOf('_samples')) ;

	var oFCKeditor = new FCKeditor( 'FCKeditor1' ) ;
	oFCKeditor.BasePath	= sBasePath ;
	oFCKeditor.ReplaceTextarea() ;
}
function getFCKValue(pId){
	var obj = document.getElementById(pId);	
	var iframeObj;
	var imgObj;
	for(f=0;f<document.frames.length;f++){
		if(document.frames[f].frames[0]){
			iframeObj = document.frames[f].frames[0].document;
			imgObj = document.frames[f].frames[0].document.getElementsByTagName("IMG");	
			break;
		}
	}
	/**
	for(i = 0; i < imgObj.length; i++){
		alert(imgObj[i]._fckflash);
		if(imgObj[i]._fckflash == "true"){
			alert(imgObj[i].src);
			alert(imgObj[i].flash_url);
			var flashObj = iframeObj.createElement("EMBED");
			flashObj.setAttribute("type","application/x-shockwave-flash");
			flashObj.setAttribute("pluginspage","http://www.macromedia.com/go/getflashplayer");
			flashObj.setAttribute("src",imgObj[i].flash_url);
			if(imgObj[i].flash_width == null || imgObj[i].flash_width == ""){
				imgObj[i].flash_width = "100%";
			}
			if(imgObj[i].flash_height == null || imgObj[i].flash_height == ""){
				imgObj[i].flash_height = "100%";
			}
			flashObj.setAttribute( 'width',imgObj[i].flash_width) ;
			flashObj.setAttribute( 'height',imgObj[i].flash_height) ;
			flashObj.setAttribute( 'id',imgObj[i].flash_id) ;
			flashObj.setAttribute( 'scale',imgObj[i].flash_scale) ;
			flashObj.setAttribute( 'play',imgObj[i].flash_play ) ;
			flashObj.setAttribute( 'loop',imgObj[i].flash_loop) ;
			flashObj.setAttribute( 'menu',imgObj[i].flash_menu) ;
			flashObj.setAttribute( 'title',imgObj[i].flash_title);
			iframeObj.body.replaceChild(flashObj,imgObj[i]);
		}
	}
	*/
	if(obj.type == "textarea"){
		obj.innerText=iframeObj.body.innerHTML;
	}else{
		obj.value=iframeObj.body.innerHTML;
	}	
}

function getEditorHTMLContents(EditorName)
{ 
    var oEditor = FCKeditorAPI.GetInstance(EditorName); 
    return(oEditor.GetXHTML(true)); 
}

function aa(){
var html = getEditorHTMLContents("FCKeditor1");
alert(html);
}

function bb(){
getFCKValue("FCKeditor1");
alert(document.getElementById("FCKeditor1").value);
}

function cc(){
	var oEditor = FCKeditorAPI.GetInstance("FCKeditor1"); 
	var oDOM = oEditor.EditorDocument; 
    var htmlvalue=oDOM.body.innerHTML;
    alert(htmlvalue);
}

	</script>
</head>
<body>
	<h1>
		FCKeditor - JavaScript - Sample 2</h1>
	<div>
		This sample displays a normal HTML form with an FCKeditor with full features enabled.
		It uses the "ReplaceTextarea" command to create the editor.
	</div>
	<hr />
	<form action="sampleposteddata.asp" method="post" target="_blank">
		<div>
			<textarea name="FCKeditor1" rows="10" cols="80" style="width: 100%; height: 200px">&lt;p&gt;This is some &lt;strong&gt;sample text&lt;/strong&gt;. You are using &lt;a href="http://www.fckeditor.net/"&gt;FCKeditor&lt;/a&gt;.&lt;/p&gt;</textarea>
		</div>
		<br />
		<input type="submit" value="Submit" />
		<input type="button" value="dddd" onclick="aa();" />
		<input type="button" value="aaa" onclick="bb();" />
		<input type="button" value="aaa" onclick="cc();" />
	</form>
</body>
</html>
